<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport"
        content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>ES9 扩展运算符与rest参数</title>
</head>
<body>
  <!--
          Rest 参数与 spread 扩展运算符在 ES6 中已经引入，不过 ES6 中只针对于数组，
          在 ES9 中为对象提供了像数组一样的 rest 参数和扩展运算符
       -->
  <script>
    //rest 参数
    function connect ({ host, port, ...user }) {
      console.log(host)
      console.log(port)
      console.log(user)
    }

    connect({
      host: '127.0.0.1',
      port: 3306,
      username: 'root',
      password: 'root',
      type: 'master',
    })

    //对象合并
    const skillOne = {
      q: '天音波',
    }

    const skillTwo = {
      w: '金钟罩',
    }

    const skillThree = {
      e: '天雷破',
    }
    const skillFour = {
      r: '猛龙摆尾',
    }

    const leeSin = { ...skillOne, ...skillTwo, ...skillThree, ...skillFour }

    console.log(leeSin)

    // ...skillOne   =>  q: '天音波', w: '金钟罩'

  </script>
</body>
</html>